package com.zhao.system.Controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhao.system.poro.Booktype;
import com.zhao.system.service.BooktypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import response.Result;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xiaozhao
 * @since 2020-11-09
 */
@RestController
@CrossOrigin(allowCredentials ="true")
@Transactional
@RequestMapping("/booktype")
public class BooktypeController {
    @Autowired
    BooktypeService booktypeService;
    @RequestMapping("/getType")
    public Result getBookType(){
        List<Booktype> list = booktypeService.list();
        return Result.ok().data("list",list);
    }
    @RequestMapping("/getBookTypeById")
    public Result getBookTypeById(@RequestParam("id")Integer id){
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.eq("tid",id);
        Booktype booktype = booktypeService.getOne(wrapper);
        return Result.ok().data("type",booktype);
    }
}

